<body>
<p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=34520">bug 34520</a>:
Assertion failure in CheckedRadioButtons::removeButton when using jQuery 1.4.1. Also tests actual
behavior the crashing jQuery was test was checking for.</p>
<script src="../../../resources/gc.js"></script>
<script>
if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}


try {
    var div = document.createElement("div");
    div.innerHTML = "<input type='radio' name='radiotest' checked='checked'/>";
    
    var fragment = document.createDocumentFragment();
    fragment.appendChild(div.firstChild);

    var clonedInput = fragment.cloneNode(true).cloneNode(true).lastChild;
    document.write((clonedInput.checked && clonedInput.getAttribute("checked") == "checked") ? "1. PASS" : "1. FAIL");
    document.write("<br>");

    // Test 2.
    div = document.createElement("div");
    div.innerHTML = "<input type='radio' name='radiotest' checked='checked'/>";
    div.firstChild.checked = false;
    
    fragment = document.createDocumentFragment();
    fragment.appendChild(div.firstChild);
    
    clonedInput = fragment.cloneNode(true).cloneNode(true).lastChild;
    document.write((!clonedInput.checked && clonedInput.getAttribute("checked") == "checked") ? "2. PASS" : "2. FAIL");
    document.write("<br>");

    // Test 3.
    div = document.createElement("div");
    div.innerHTML = "<input type='radio' name='radiotest'/>";
    div.firstChild.checked = true;
    
    fragment = document.createDocumentFragment();
    fragment.appendChild(div.firstChild);
    
    clonedInput = fragment.cloneNode(true).cloneNode(true).lastChild;
    document.write((clonedInput.checked && clonedInput.getAttribute("checked") == null) ? "3. PASS" : "3. FAIL");

    document.write("<br>DONE");

    setTimeout(function() {
        gc();
        if (window.testRunner)
            testRunner.notifyDone();
    }, 0);
} catch (ex) {
    document.write("FAIL: " + ex);
}
</script>
</body>
